package offer.secnod;

import listNodePractice.ListNode;

import java.util.ArrayList;

public class Offer06 {
    ArrayList<Integer> res1 = new ArrayList<>();
    public int[] reverse(ListNode list){
        if (list==null){
            return  new int[0];
        }
        digui(list);
        int[] res = new int[res1.size()];
        int i=0;
        for (int a: res1) {
            res[i++]=a;

        }
        return  res;

    }
    public  void  digui(ListNode listNode){
        if (listNode==null){
            return;
        }
        digui(listNode.next);
        res1.add(listNode.val);

    }


}
